"""
功能描述 ：
编写人 ：
编写日期 ：
实现逻辑 ：
    1- ......
        1.1- ......
    2- ......
        2.1- ......
"""
#python数据类型：str float str list tuple dict boolber

#可变数据类型：list dict set

#不可变数据类型：int float str 布尔

# 格式符号：%s 字符串、%d 整数、%f 浮点数
# %02d、%.2f
# f'{表达式}'
# 例子：
# age = 18
# name = "chenyusong"
# weight = 65.5
# id = 1
# print('%s的年龄是%d，体重是%.2f，学号是%04d' %(name,age,weight,id))
# print(f'年龄是{age},姓名{name}体重是{weight},标识是{id}')
"""类型转换"""
# num = int(input('请输入一个数字：'))
# print(f'输入的数字职{num}')
# print(type(num))
# print(type(int()))

# list = [1,2,3]
# print(type(list))
# print(type(type(list)))
#
# str1 = '123'
# str2 = '[1,2,3]'
# str3 = '(1,2,3)'
# print(type(eval(str1)))
# print(type(eval(str2)))
# print(type(eval(str3)))
#
# #字符串切片，下标
# str1 = 'abcdfeg'
# print(str1[0])
# print(str1[2:5:1])
# print(str1[2:])
# print(str1[:5])
# print(str1[::2])
# print(str1[:-1])
# print(str1[::-2])
# print(str1[-4:-1:2])
#
# #常用操作方法一
# # find查找不到返回-1 index找不到报错 count
# str1 = "hello world and superctest and chaoge and Python"
# print(str1.index('and'))
# print(str1.find('and'))
# print(str1.find('and',1,5))
# print(str1.count('and'))
# print(str1.count('ands'))
# print(str1.count('and',1,15))
#
# #常用方法二
# # replace——替换 split——分割字符串 join——合并字符串 strip——删除空白字符
# str1 = "hello world and superctest and chaoge and Python"
# print(str1.replace('and','or'))
# print((str1.replace('and','he',2)))
# print(str1.split('and'))
# print(str1.split('and',2))
# print(str1.split(' '))
#
# list1 = ['hello world ', ' superctest ', ' chaoge ', ' Python']
# print('and'.join(list1))
#
# str2 = "  hello world and superctest and chaoge and Python  "
# print(str2.strip())
# print(str2.lstrip())
# print(str2.rsplit())
#
# #常用方法三
# # capitalize——第一个字符转换成大写 title——每个单词首字母大写 lower——大写转小写 upper——小写转大写
# str1 = "hello world and superctest and chaoge and Python"
# str2 = 'HELLO WORLD AND SUPERCTEST AND CHAOGE AND PYTHON'
#
# print(str1.capitalize())
# print(str1.title())
# print(str2.lower())
# print(str1.upper())
# #常用方法四
# # ljust——左对齐 rjust——右对齐 center——居中对齐
# str1 = "hello"
# print(str1.ljust())
# print(str1.rjust())
# print(str1.center())

# #坐公交
# """if else实例：坐公交
#     如果有钱，则可以上⻋
#         上⻋后，如果有空座，可以坐下
#         上⻋后，如果没有空座，则站着等空座位
#     如果没钱，不能上⻋"""
#
# money = int(input('请输入1或0,1代表有钱，0代表没钱：'))
# if money == "1":
#     print('有钱请上车')
#     sit = int(input('请输入0-20整数,0代表没坐：'))
#     if sit == '0':
#         print("无座")
#     else:
#         print("有座位")
# else:
#     print("mei钱不可上车")
#
# # ?练习：猜拳游
# import random
# computer = random.randint(0,2)
# print(computer)
# player = int(input("请输入0-2整数，0-石头，1-剪刀，2-布："))
# if computer == 0:
#     if player == 1:
#         print('电脑获胜')
#     elif player == 2:
#         print('您赢了')
# if computer == 1:
#     if player == 2:
#         print('电脑获胜')
#     elif player == 0:
#         print('您赢了')
# if computer == 2:
#     if player == 0:
#         print('电脑获胜')
#     elif player == 1:
#         print('您赢了')
# if computer == player:
#     print("平局")
# # while循环
# # 应⽤⼀：计算1-100累加和
# i = 1
# n = 0
# while i <100:
#     if i%2 ==2:
#         n += i
#     i += 1
#     print(n)

#while循环嵌套
#打印整星号正方形
j=1
while j<5:
    i=1
    while i<5:
        print("*",end='')
        i+=1
    print("")
    j+=1


#九九乘法表
j = 1
while j <= 9:
    i = 1
    while i <= j:
        print(f'{i}*{j} = {j * i}', end = '/t')
        i += 1
    print()
    j +=1
#for 循环
str1 = 'chenyusong'
for i in str1:
    print(i)
#break退出整个循环和contin退出本次循环，继续下一次
str1 = 'chenyusong'
for i in str1:
    if i =='e':
        print("遇到e不打印")
        break
    print(i)

str1 = 'hello'
for i in str1:
    if i == 'e':
        print("遇到e不打印")
        continue
    print(i)
#whiel else

i = 1
while i <= 5:
    print('有问题')
    i +=1
else:
    print('没问题')

#退出循环的方式
i = 1
while i <= 5:
    if i <= 3:
        print('有问题')
    break
    print()
    i +=1
else:
    print('没问题')

i = 1
while i <= 5:
    if i <= 3:
        print('有问题')
    continue
    print()
    i +=1
else:
    print('没问题')

#for...else

str1 = 'chenyusong'
for i in str1:
    print(i)
else:
    print("正常结束")

str1 = 'chenyusong'
for i in str1:
    if i == 'e':
        print('遇到e不打印')
        break
    print(i)
else:
    print('正常结束')

str1 = 'chenyusong'
for i in str1:
    if i == 'e':
        print('遇到e不打印')
        continue
    print(i)
else:
    print('正常结束')